<!DOCTYPE html>
<!-- saved from url=(0041)http://c.biancheng.net/view/vip_7080.html -->
<html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script type="text/javascript" async="" charset="utf-8" src="./11.22Java项目实战：模仿斗地主洗牌发牌小游戏（附带源码和解析）_files/core.php"></script><script async="" src="./11.22Java项目实战：模仿斗地主洗牌发牌小游戏（附带源码和解析）_files/click.php"></script>

<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<!-- 启用Chromium高速渲染模式 -->
<meta name="renderer" content="webkit">
<meta name="force-rendering" content="webkit">
<!-- 禁止百度转码 -->
<meta name="applicable-device" content="pc,mobile">
<meta name="MobileOptimized" content="width">
<meta name="HandheldFriendly" content="true">
<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
<!-- 禁止识别电话号码 -->
<meta name="format-detection" content="telephone=no">

<link rel="shortcut icon" href="http://c.biancheng.net/favicon.ico?v=1.6.72">
<link href="./11.22Java项目实战：模仿斗地主洗牌发牌小游戏（附带源码和解析）_files/common.css" rel="stylesheet">
<title>Java项目实战：模仿斗地主洗牌发牌小游戏（附带源码和解析）</title>
<meta name="description" content="斗地主是全国范围内的一种桌面游戏，尽管全国各种类型，但大同小异。本节我们先来实现一下斗地主中的简单洗牌、发牌和看牌功能。 按照斗地主的规则，完成洗牌发牌的动作。具体">
</head>
<body>
<div id="topbar" class="clearfix">
	<ul id="product-type" class="left">
		<li>
			<a href="http://c.biancheng.net/"><span class="iconfont iconfont-home"></span>首页</a>
		</li>
		<li class="active">
			<a href="http://c.biancheng.net/sitemap/" rel="nofollow"><span class="iconfont iconfont-book"></span>教程</a>
		</li>
		<li>
			<a href="http://vip.biancheng.net/p/vip/show.php" rel="nofollow" target="_blank"><span class="iconfont iconfont-vip"></span>VIP会员</a>
		</li>
		<li>
			<a href="http://vip.biancheng.net/p/q2a/show.php" rel="nofollow" target="_blank"><span class="iconfont iconfont-q2a"></span>一对一答疑</a>
		</li>
		<li>
			<a href="http://fudao.biancheng.net/" rel="nofollow" target="_blank"><span class="iconfont iconfont-fudao"></span>辅导班</a>
		</li>
	</ul>
</div>
<div id="header" class="clearfix">
	<a id="logo" class="left" href="http://c.biancheng.net/">
		<img height="26" src="./11.22Java项目实战：模仿斗地主洗牌发牌小游戏（附带源码和解析）_files/logo.png" alt="C语言中文网">
	</a>
	<ul id="nav-main" class="hover-none left clearfix">
		<li class="wap-yes"><a href="http://c.biancheng.net/">首页</a></li>
		<li><a href="http://c.biancheng.net/c/">C语言教程</a></li>
		<li><a href="http://c.biancheng.net/cplus/">C++教程</a></li>
		<li><a href="http://c.biancheng.net/python/">Python教程</a></li>
		<li><a href="http://c.biancheng.net/java/">Java教程</a></li>
		<li><a href="http://c.biancheng.net/linux_tutorial/">Linux入门</a></li>
		<li><a href="http://c.biancheng.net/sitemap/" title="网站地图">更多&gt;&gt;</a></li>
	</ul>
	<span id="sidebar-toggle" class="toggle-btn" toggle-target="#sidebar">目录 <span class="glyphicon"></span></span>

	<a href="http://vip.biancheng.net/?from=topbar" class="user-info glyphicon glyphicon-user hover-none" target="_blank" rel="nofollow" title="用户中心"></a>
</div>
<div id="main" class="clearfix">
	<div id="sidebar" class="toggle-target">
	<div id="contents">
		<dt><span class="glyphicon glyphicon-option-vertical" aria-hidden="true"></span><a href="http://c.biancheng.net/java/">Java教程</a></dt>
		
			<dd>
				<span class="channel-num">1</span>
				<a href="http://c.biancheng.net/java/10/">Java入门基础及环境搭建</a>
			</dd>
		
			<dd>
				<span class="channel-num">2</span>
				<a href="http://c.biancheng.net/java/20/">Java程序设计基础</a>
			</dd>
		
			<dd>
				<span class="channel-num">3</span>
				<a href="http://c.biancheng.net/java/30/">Java流程控制语句</a>
			</dd>
		
			<dd>
				<span class="channel-num">4</span>
				<a href="http://c.biancheng.net/java/40/">Java字符串处理</a>
			</dd>
		
			<dd>
				<span class="channel-num">5</span>
				<a href="http://c.biancheng.net/java/50/">Java数字和日期处理</a>
			</dd>
		
			<dd>
				<span class="channel-num">6</span>
				<a href="http://c.biancheng.net/java/60/">Java内置包装类</a>
			</dd>
		
			<dd>
				<span class="channel-num">7</span>
				<a href="http://c.biancheng.net/java/70/">Java数组处理</a>
			</dd>
		
			<dd>
				<span class="channel-num">8</span>
				<a href="http://c.biancheng.net/java/80/">Java类和对象</a>
			</dd>
		
			<dd>
				<span class="channel-num">9</span>
				<a href="http://c.biancheng.net/java/90/">Java继承和多态</a>
			</dd>
		
			<dd>
				<span class="channel-num">10</span>
				<a href="http://c.biancheng.net/java/100/">Java异常处理</a>
			</dd>
		<dd class="this"> <span class="channel-num">11</span> <a href="http://c.biancheng.net/java/110/">Java集合、泛型和枚举</a> </dd><dl class="dl-sub"><dd>11.1 <a href="http://c.biancheng.net/view/6824.html">Java集合</a></dd><dd>11.2 <a href="http://c.biancheng.net/view/6782.html">Java Collection接口</a></dd><dd>11.3 <a href="http://c.biancheng.net/view/6843.html">Java List集合</a></dd><dd>11.4 <a href="http://c.biancheng.net/view/6847.html">Java Set集合</a></dd><dd>11.5 <a href="http://c.biancheng.net/view/6868.html">Java Map集合</a></dd><dd>11.6 <a href="http://c.biancheng.net/view/6872.html">Java遍历Map集合</a></dd><dd>11.7 <a href="http://c.biancheng.net/view/vip_7078.html">Java 8中Map新增的方法</a><span class="glyphicon glyphicon-usd"></span></dd><dd>11.8 <a href="http://c.biancheng.net/view/6884.html">Java Collections类</a></dd><dd>11.9 <a href="http://c.biancheng.net/view/6793.html">Lambda表达式遍历Collection集合</a></dd><dd>11.10 <a href="http://c.biancheng.net/view/6795.html">使用迭代器遍历集合元素</a></dd><dd>11.11 <a href="http://c.biancheng.net/view/6797.html">Java Lambda表达式遍历迭代器</a></dd><dd>11.12 <a href="http://c.biancheng.net/view/6798.html">Java foreach遍历Collection集合</a></dd><dd>11.13 <a href="http://c.biancheng.net/view/6802.html">Predicate操作Collection集合</a></dd><dd>11.14 <a href="http://c.biancheng.net/view/6805.html">Stream操作Collection集合</a></dd><dd>11.15 <a href="http://c.biancheng.net/view/6894.html">Java 9新增的不可变集合</a></dd><dd>11.16 <a href="http://c.biancheng.net/view/vip_7079.html">Java 9中增强的“菱形”语法</a><span class="glyphicon glyphicon-usd"></span></dd><dd>11.17 <a href="http://c.biancheng.net/view/1085.html">Java泛型</a></dd><dd>11.18 <a href="http://c.biancheng.net/view/1094.html">Java图书信息查询</a></dd><dd>11.19 <a href="http://c.biancheng.net/view/1100.html">Java枚举</a></dd><dd>11.20 <a href="http://c.biancheng.net/view/6854.html">Java一对多关系示例</a></dd><dd>11.21 <a href="http://c.biancheng.net/view/6867.html">Java多对多关系示例</a></dd><dd class="active">11.22 <a href="http://c.biancheng.net/view/vip_7080.html">【Java项目实战】模仿斗地主洗牌发牌小游戏（附带源码和解析）</a><span class="glyphicon glyphicon-usd"></span></dd></dl>
			<dd>
				<span class="channel-num">12</span>
				<a href="http://c.biancheng.net/java/120/">Java反射机制</a>
			</dd>
		
			<dd>
				<span class="channel-num">13</span>
				<a href="http://c.biancheng.net/java/130/">Java输入/输出流</a>
			</dd>
		
			<dd>
				<span class="channel-num">14</span>
				<a href="http://c.biancheng.net/java/java/135/">Java注解</a>
			</dd>
		
	</div>
</div>
	<div id="article-wrap">
		<div id="article">
			<div class="arc-info">
	<span class="position"><span class="glyphicon glyphicon-map-marker"></span> <a href="http://c.biancheng.net/">首页</a> &gt; <a href="http://c.biancheng.net/java/">Java教程</a> &gt; <a href="http://c.biancheng.net/java/110/">Java集合、泛型和枚举</a></span>
	<span class="read-num">阅读：4,263</span>
</div>

<div id="ad-position-bottom"></div>
			<h1>Java项目实战：模仿斗地主洗牌发牌小游戏（附带源码和解析）</h1>
			<div class="pre-next-page clearfix">
                    <span class="pre left"><span class="icon">&lt;</span> <span class="text-brief text-brief-pre">上一页</span><a href="http://c.biancheng.net/view/6867.html">Java多对多关系示例</a></span>
                    <span class="next right"><a href="http://c.biancheng.net/java/120/">Java反射机制</a><span class="text-brief text-brief-next">下一页</span> <span class="icon">&gt;</span></span>
                </div>
			<div id="ad-arc-top"><p class="pic"></p><p class="text" adid="java-1v1q2a"><a href="http://c.biancheng.net/view/7552.html" target="_blank" style="color: #D33428;">C语言中文网推出辅导班啦，包括<span style="color: #008000;">「C语言辅导班、C++辅导班、算法/数据结构辅导班」</span>，全部都是一对一教学：一对一辅导 + 一对一答疑 + 布置作业 + 项目实践 + 永久学习。QQ在线，随时响应！</a></p></div>
			<div id="arc-body">斗地主是全国范围内的一种桌面游戏，尽管全国各种类型，但大同小异。本节我们先来实现一下斗地主中的简单洗牌、发牌和看牌功能。<br>
<br>
按照斗地主的规则，完成洗牌发牌的动作。具体规则为使用 54 张牌打乱顺序，3 个玩家参与游戏，3 人交替摸牌，每人 17 张牌，后 3 张留作底牌。&nbsp;<br>
<br>
实现思路步骤如下：<br>
<ol>
	<li>
		准备牌：Arrylist 集合储存，for 循环遍历实现</li>
	<li>
		洗牌：使用 Collections 的<code>shuffle(arryBox);</code>方法刷新集合中的顺序</li>
	<li>
		发牌：使用 for 循环遍历 Arrylist 中的 51 张牌，然后用索引值对 3 取余，余数为 0，1，2 然后来随机分配牌。</li>
	<li>
		看牌：直接输出集合</li>
</ol>
<br>
实现代码如下：
<div class="snippet-container" style="undefined;"><div class="sh_bright snippet-wrap"><div class="snippet-menu sh_sourceCode" style="display: none;"><pre><a class="snippet-copy sh_url" href="http://c.biancheng.net/view/vip_7080.html#" style="display: none;">复制</a><a class="snippet-text sh_url" href="http://c.biancheng.net/view/vip_7080.html#">纯文本</a><a class="snippet-window sh_url" href="http://c.biancheng.net/view/vip_7080.html#">复制</a></pre></div><pre class="java sh_java snippet-formatted sh_sourceCode"><ol class="snippet-num"><li><span class="sh_keyword">public</span> <span class="sh_keyword">class</span><span class="sh_normal"> </span><span class="sh_classname">Main</span> <span class="sh_cbracket">{</span></li><li>    <span class="sh_keyword">public</span> <span class="sh_keyword">static</span> <span class="sh_type">void</span> <span class="sh_function">main</span><span class="sh_symbol">(</span>String<span class="sh_symbol">[]</span> args<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>        <span class="sh_comment">// 1. 准备牌</span></li><li>        String<span class="sh_symbol">[]</span> arr1 <span class="sh_symbol">=</span> <span class="sh_cbracket">{</span> <span class="sh_string">"黑桃"</span><span class="sh_symbol">,</span> <span class="sh_string">"红桃"</span><span class="sh_symbol">,</span> <span class="sh_string">"方片"</span><span class="sh_symbol">,</span> <span class="sh_string">"梅花"</span> <span class="sh_cbracket">}</span><span class="sh_symbol">;</span></li><li>        String<span class="sh_symbol">[]</span> arr2 <span class="sh_symbol">=</span> <span class="sh_cbracket">{</span> <span class="sh_string">"A"</span><span class="sh_symbol">,</span> <span class="sh_string">"2"</span><span class="sh_symbol">,</span> <span class="sh_string">"3"</span><span class="sh_symbol">,</span> <span class="sh_string">"4"</span><span class="sh_symbol">,</span> <span class="sh_string">"5"</span><span class="sh_symbol">,</span> <span class="sh_string">"6"</span><span class="sh_symbol">,</span> <span class="sh_string">"7"</span><span class="sh_symbol">,</span> <span class="sh_string">"8"</span><span class="sh_symbol">,</span> <span class="sh_string">"9"</span><span class="sh_symbol">,</span> <span class="sh_string">"10"</span><span class="sh_symbol">,</span> <span class="sh_string">"J"</span><span class="sh_symbol">,</span> <span class="sh_string">"Q"</span><span class="sh_symbol">,</span> <span class="sh_string">"K"</span> <span class="sh_cbracket">}</span><span class="sh_symbol">;</span></li><li>        <span class="sh_usertype">List&lt;String&gt;</span><span class="sh_normal"> </span>arryBox <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> ArrayList<span class="sh_symbol">&lt;&gt;();</span></li><li>        <span class="sh_keyword">for</span> <span class="sh_symbol">(</span><span class="sh_type">int</span> i <span class="sh_symbol">=</span> <span class="sh_number">0</span><span class="sh_symbol">;</span> i <span class="sh_symbol">&lt;</span> arr1<span class="sh_symbol">.</span>length<span class="sh_symbol">;</span> i<span class="sh_symbol">++)</span> <span class="sh_cbracket">{</span></li><li>            <span class="sh_keyword">for</span> <span class="sh_symbol">(</span><span class="sh_type">int</span> j <span class="sh_symbol">=</span> <span class="sh_number">0</span><span class="sh_symbol">;</span> j <span class="sh_symbol">&lt;</span> arr2<span class="sh_symbol">.</span>length<span class="sh_symbol">;</span> j<span class="sh_symbol">++)</span> <span class="sh_cbracket">{</span></li><li>                arryBox<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span>arr1<span class="sh_symbol">[</span>i<span class="sh_symbol">]</span> <span class="sh_symbol">+</span> arr2<span class="sh_symbol">[</span>j<span class="sh_symbol">]);</span></li><li>            <span class="sh_cbracket">}</span></li><li>        <span class="sh_cbracket">}</span></li><li>        arryBox<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span><span class="sh_string">"大王"</span><span class="sh_symbol">);</span></li><li>        arryBox<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span><span class="sh_string">"小王"</span><span class="sh_symbol">);</span></li><li>        <span class="sh_comment">// 3个人斗地主，分别为 zhangsan、lisi、wangwu</span></li><li>        <span class="sh_usertype">List&lt;String&gt;</span><span class="sh_normal"> </span>zhangsan <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> ArrayList<span class="sh_symbol">&lt;&gt;();</span></li><li>        <span class="sh_usertype">List&lt;String&gt;</span><span class="sh_normal"> </span>lisi <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> ArrayList<span class="sh_symbol">&lt;&gt;();</span></li><li>        <span class="sh_usertype">List&lt;String&gt;</span><span class="sh_normal"> </span>wangwu <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> ArrayList<span class="sh_symbol">&lt;&gt;();</span></li><li>        <span class="sh_comment">// 2. 洗牌</span></li><li>        Collections<span class="sh_symbol">.</span><span class="sh_function">shuffle</span><span class="sh_symbol">(</span>arryBox<span class="sh_symbol">);</span></li><li>        <span class="sh_comment">// 3. 发牌</span></li><li>        <span class="sh_keyword">for</span> <span class="sh_symbol">(</span><span class="sh_type">int</span> i <span class="sh_symbol">=</span> <span class="sh_number">0</span><span class="sh_symbol">;</span> i <span class="sh_symbol">&lt;</span> arryBox<span class="sh_symbol">.</span><span class="sh_function">size</span><span class="sh_symbol">()</span> <span class="sh_symbol">-</span> <span class="sh_number">3</span><span class="sh_symbol">;</span> i<span class="sh_symbol">++)</span> <span class="sh_cbracket">{</span></li><li>            <span class="sh_keyword">if</span> <span class="sh_symbol">(</span>i <span class="sh_symbol">%</span> <span class="sh_number">3</span> <span class="sh_symbol">==</span> <span class="sh_number">0</span><span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>                zhangsan<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span>arryBox<span class="sh_symbol">.</span><span class="sh_function">get</span><span class="sh_symbol">(</span>i<span class="sh_symbol">));</span></li><li>            <span class="sh_cbracket">}</span> <span class="sh_keyword">else</span> <span class="sh_keyword">if</span> <span class="sh_symbol">(</span>i <span class="sh_symbol">%</span> <span class="sh_number">3</span> <span class="sh_symbol">==</span> <span class="sh_number">1</span><span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>                lisi<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span>arryBox<span class="sh_symbol">.</span><span class="sh_function">get</span><span class="sh_symbol">(</span>i<span class="sh_symbol">));</span></li><li>            <span class="sh_cbracket">}</span> <span class="sh_keyword">else</span> <span class="sh_keyword">if</span> <span class="sh_symbol">(</span>i <span class="sh_symbol">%</span> <span class="sh_number">3</span> <span class="sh_symbol">==</span> <span class="sh_number">2</span><span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>                wangwu<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span>arryBox<span class="sh_symbol">.</span><span class="sh_function">get</span><span class="sh_symbol">(</span>i<span class="sh_symbol">));</span></li><li>            <span class="sh_cbracket">}</span></li><li>        <span class="sh_cbracket">}</span></li><li>        <span class="sh_comment">// 4. 看牌</span></li><li>        <span class="sh_function">pushBoss</span><span class="sh_symbol">();</span></li><li>        System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">println</span><span class="sh_symbol">(</span><span class="sh_string">"张三："</span> <span class="sh_symbol">+</span> zhangsan<span class="sh_symbol">);</span></li><li>        System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">println</span><span class="sh_symbol">(</span><span class="sh_string">"李四："</span> <span class="sh_symbol">+</span> lisi<span class="sh_symbol">);</span></li><li>        System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">println</span><span class="sh_symbol">(</span><span class="sh_string">"王五："</span> <span class="sh_symbol">+</span> wangwu<span class="sh_symbol">);</span></li><li>        System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">print</span><span class="sh_symbol">(</span><span class="sh_string">"底牌：["</span><span class="sh_symbol">);</span></li><li>        <span class="sh_keyword">for</span> <span class="sh_symbol">(</span><span class="sh_type">int</span> i <span class="sh_symbol">=</span> <span class="sh_number">1</span><span class="sh_symbol">;</span> i <span class="sh_symbol">&lt;</span> <span class="sh_number">4</span><span class="sh_symbol">;</span> i<span class="sh_symbol">++)</span> <span class="sh_cbracket">{</span></li><li>            System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">print</span><span class="sh_symbol">(</span>arryBox<span class="sh_symbol">.</span><span class="sh_function">get</span><span class="sh_symbol">(</span>arryBox<span class="sh_symbol">.</span><span class="sh_function">size</span><span class="sh_symbol">()</span> <span class="sh_symbol">-</span> i<span class="sh_symbol">));</span></li><li>            <span class="sh_keyword">if</span> <span class="sh_symbol">(</span>i <span class="sh_symbol">&lt;</span> <span class="sh_number">3</span><span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>                System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">print</span><span class="sh_symbol">(</span><span class="sh_string">","</span><span class="sh_symbol">);</span></li><li>            <span class="sh_cbracket">}</span></li><li>        <span class="sh_cbracket">}</span></li><li>        System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">print</span><span class="sh_symbol">(</span><span class="sh_string">"]"</span><span class="sh_symbol">);</span></li><li><span style="display:none;">&nbsp;</span></li><li>    <span class="sh_cbracket">}</span></li><li><span style="display:none;">&nbsp;</span></li><li>    <span class="sh_comment">/** 随机地主 */</span></li><li>    <span class="sh_keyword">public</span> <span class="sh_keyword">static</span> <span class="sh_type">void</span> <span class="sh_function">pushBoss</span><span class="sh_symbol">()</span> <span class="sh_cbracket">{</span></li><li>        <span class="sh_usertype">List&lt;String&gt;</span><span class="sh_normal"> </span>players <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> ArrayList<span class="sh_symbol">&lt;</span>String<span class="sh_symbol">&gt;();</span></li><li>        players<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span><span class="sh_string">"张三"</span><span class="sh_symbol">);</span></li><li>        players<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span><span class="sh_string">"李四"</span><span class="sh_symbol">);</span></li><li>        players<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span><span class="sh_string">"王五"</span><span class="sh_symbol">);</span></li><li>        <span class="sh_usertype">Random</span><span class="sh_normal"> </span>r <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> <span class="sh_function">Random</span><span class="sh_symbol">();</span></li><li>        <span class="sh_type">int</span> bossIndex <span class="sh_symbol">=</span> r<span class="sh_symbol">.</span><span class="sh_function">nextInt</span><span class="sh_symbol">(</span><span class="sh_number">3</span><span class="sh_symbol">);</span></li><li>        <span class="sh_usertype">String</span><span class="sh_normal"> </span>boss <span class="sh_symbol">=</span> players<span class="sh_symbol">.</span><span class="sh_function">get</span><span class="sh_symbol">(</span>bossIndex<span class="sh_symbol">);</span></li><li>        System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">println</span><span class="sh_symbol">(</span><span class="sh_string">"此局地主是："</span> <span class="sh_symbol">+</span> boss<span class="sh_symbol">);</span></li><li>    <span class="sh_cbracket">}</span></li><li><span class="sh_cbracket">}</span></li></ol></pre><pre class="snippet-textonly sh_sourceCode" style="display:none;">public class Main {
    public static void main(String[] args) {
        // 1. 准备牌
        String[] arr1 = { "黑桃", "红桃", "方片", "梅花" };
        String[] arr2 = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };
        List&lt;String&gt; arryBox = new ArrayList&lt;&gt;();
        for (int i = 0; i &lt; arr1.length; i++) {
            for (int j = 0; j &lt; arr2.length; j++) {
                arryBox.add(arr1[i] + arr2[j]);
            }
        }
        arryBox.add("大王");
        arryBox.add("小王");
        // 3个人斗地主，分别为 zhangsan、lisi、wangwu
        List&lt;String&gt; zhangsan = new ArrayList&lt;&gt;();
        List&lt;String&gt; lisi = new ArrayList&lt;&gt;();
        List&lt;String&gt; wangwu = new ArrayList&lt;&gt;();
        // 2. 洗牌
        Collections.shuffle(arryBox);
        // 3. 发牌
        for (int i = 0; i &lt; arryBox.size() - 3; i++) {
            if (i % 3 == 0) {
                zhangsan.add(arryBox.get(i));
            } else if (i % 3 == 1) {
                lisi.add(arryBox.get(i));
            } else if (i % 3 == 2) {
                wangwu.add(arryBox.get(i));
            }
        }
        // 4. 看牌
        pushBoss();
        System.out.println("张三：" + zhangsan);
        System.out.println("李四：" + lisi);
        System.out.println("王五：" + wangwu);
        System.out.print("底牌：[");
        for (int i = 1; i &lt; 4; i++) {
            System.out.print(arryBox.get(arryBox.size() - i));
            if (i &lt; 3) {
                System.out.print(",");
            }
        }
        System.out.print("]");

    }

    /** 随机地主 */
    public static void pushBoss() {
        List&lt;String&gt; players = new ArrayList&lt;String&gt;();
        players.add("张三");
        players.add("李四");
        players.add("王五");
        Random r = new Random();
        int bossIndex = r.nextInt(3);
        String boss = players.get(bossIndex);
        System.out.println("此局地主是：" + boss);
    }
}</pre></div></div>
运行上面程序，输出结果为：
<p class="info-box">
	此局地主是：李四<br>
	张三： [梅花10, 方片2, 方片K, 方片J, 方片5, 黑桃6, 黑桃10, 红桃3, 梅花3, 黑桃2, 梅花8, 黑桃A, 红桃J, 梅花9, 红桃K, 方片9, 梅花Q]<br>
	李四： [红桃4, 黑桃8, 方片8, 方片3, 红桃2, 红桃6, 红桃5, 黑桃3, 黑桃4, 梅花7, 方片Q, 小王, 红桃8, 黑桃K, 方片6, 梅花A, 黑桃7]<br>
	王五： [方片4, 梅花4, 方片7, 黑桃5, 黑桃9, 红桃10, 梅花K, 方片A, 红桃Q, 黑桃J, 梅花2, 大王, 方片10, 红桃A, 梅花J, 梅花5, 红桃7]<br>
	底牌：[梅花6,红桃9,黑桃Q]</p>
可通过 Map 集合将三名玩家的牌按大小排序，实现代码如下：
<div class="snippet-container" style="undefined;"><div class="sh_bright snippet-wrap"><div class="snippet-menu sh_sourceCode" style="display:none;"><pre><a class="snippet-copy sh_url" href="http://c.biancheng.net/view/vip_7080.html#" style="display: none;">复制</a><a class="snippet-text sh_url" href="http://c.biancheng.net/view/vip_7080.html#">纯文本</a><a class="snippet-window sh_url" href="http://c.biancheng.net/view/vip_7080.html#">复制</a></pre></div><pre class="java sh_java snippet-formatted sh_sourceCode"><ol class="snippet-num"><li><span class="sh_keyword">public</span> <span class="sh_keyword">class</span><span class="sh_normal"> </span><span class="sh_classname">Main2</span> <span class="sh_cbracket">{</span></li><li>    <span class="sh_keyword">public</span> <span class="sh_keyword">static</span> <span class="sh_type">void</span> <span class="sh_function">main</span><span class="sh_symbol">(</span>String<span class="sh_symbol">[]</span> args<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>        <span class="sh_comment">// 1.准备牌</span></li><li>        String<span class="sh_symbol">[]</span> arr1 <span class="sh_symbol">=</span> <span class="sh_cbracket">{</span> <span class="sh_string">"黑桃"</span><span class="sh_symbol">,</span> <span class="sh_string">"红桃"</span><span class="sh_symbol">,</span> <span class="sh_string">"方片"</span><span class="sh_symbol">,</span> <span class="sh_string">"梅花"</span> <span class="sh_cbracket">}</span><span class="sh_symbol">;</span></li><li>        String<span class="sh_symbol">[]</span> arr2 <span class="sh_symbol">=</span> <span class="sh_cbracket">{</span> <span class="sh_string">"A"</span><span class="sh_symbol">,</span> <span class="sh_string">"2"</span><span class="sh_symbol">,</span> <span class="sh_string">"3"</span><span class="sh_symbol">,</span> <span class="sh_string">"4"</span><span class="sh_symbol">,</span> <span class="sh_string">"5"</span><span class="sh_symbol">,</span> <span class="sh_string">"6"</span><span class="sh_symbol">,</span> <span class="sh_string">"7"</span><span class="sh_symbol">,</span> <span class="sh_string">"8"</span><span class="sh_symbol">,</span> <span class="sh_string">"9"</span><span class="sh_symbol">,</span> <span class="sh_string">"10"</span><span class="sh_symbol">,</span> <span class="sh_string">"J"</span><span class="sh_symbol">,</span> <span class="sh_string">"Q"</span><span class="sh_symbol">,</span> <span class="sh_string">"K"</span> <span class="sh_cbracket">}</span><span class="sh_symbol">;</span></li><li><span style="display:none;">&nbsp;</span></li><li>        <span class="sh_comment">// 定义Map集合用来存放索引和牌</span></li><li>        <span class="sh_usertype">HashMap&lt;Integer, String&gt;</span><span class="sh_normal"> </span>pokerMap <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> HashMap<span class="sh_symbol">&lt;&gt;();</span></li><li>        <span class="sh_comment">// 定义List集合存储索引（索引为0-53）</span></li><li>        <span class="sh_usertype">List&lt;Integer&gt;</span><span class="sh_normal"> </span>indexList <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> ArrayList<span class="sh_symbol">&lt;&gt;();</span></li><li>        <span class="sh_comment">// 定义索引值变量</span></li><li>        <span class="sh_type">int</span> index <span class="sh_symbol">=</span> <span class="sh_number">0</span><span class="sh_symbol">;</span></li><li>        <span class="sh_comment">// 将扑克牌与索引建立对应关系放入Map和List集合中</span></li><li>        <span class="sh_keyword">for</span> <span class="sh_symbol">(</span><span class="sh_usertype">String</span><span class="sh_normal"> </span>num <span class="sh_symbol">:</span> arr2<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>            <span class="sh_keyword">for</span> <span class="sh_symbol">(</span><span class="sh_usertype">String</span><span class="sh_normal"> </span>color <span class="sh_symbol">:</span> arr1<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>                pokerMap<span class="sh_symbol">.</span><span class="sh_function">put</span><span class="sh_symbol">(</span>index<span class="sh_symbol">,</span> color <span class="sh_symbol">+</span> num<span class="sh_symbol">);</span></li><li>                indexList<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span>index<span class="sh_symbol">);</span></li><li>                index<span class="sh_symbol">++;</span></li><li>            <span class="sh_cbracket">}</span></li><li>        <span class="sh_cbracket">}</span></li><li>        pokerMap<span class="sh_symbol">.</span><span class="sh_function">put</span><span class="sh_symbol">(</span>index<span class="sh_symbol">,</span> <span class="sh_string">"小王"</span><span class="sh_symbol">);</span></li><li>        indexList<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span>index<span class="sh_symbol">++);</span></li><li>        pokerMap<span class="sh_symbol">.</span><span class="sh_function">put</span><span class="sh_symbol">(</span>index<span class="sh_symbol">,</span> <span class="sh_string">"大王"</span><span class="sh_symbol">);</span></li><li>        indexList<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span>index<span class="sh_symbol">);</span></li><li><span style="display:none;">&nbsp;</span></li><li>        <span class="sh_comment">// 定义玩家</span></li><li>        <span class="sh_usertype">TreeSet&lt;Integer&gt;</span><span class="sh_normal"> </span>zhangsan <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> TreeSet<span class="sh_symbol">&lt;&gt;();</span></li><li>        <span class="sh_usertype">TreeSet&lt;Integer&gt;</span><span class="sh_normal"> </span>lisi <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> TreeSet<span class="sh_symbol">&lt;&gt;();</span></li><li>        <span class="sh_usertype">TreeSet&lt;Integer&gt;</span><span class="sh_normal"> </span>wangwu <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> TreeSet<span class="sh_symbol">&lt;&gt;();</span></li><li>        <span class="sh_usertype">TreeSet&lt;Integer&gt;</span><span class="sh_normal"> </span>buttoms <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> TreeSet<span class="sh_symbol">&lt;&gt;();</span></li><li><span style="display:none;">&nbsp;</span></li><li>        <span class="sh_comment">// 2. 洗牌</span></li><li>        Collections<span class="sh_symbol">.</span><span class="sh_function">shuffle</span><span class="sh_symbol">(</span>indexList<span class="sh_symbol">);</span></li><li>        <span class="sh_comment">// 3. 发牌</span></li><li>        <span class="sh_keyword">for</span> <span class="sh_symbol">(</span><span class="sh_type">int</span> i <span class="sh_symbol">=</span> <span class="sh_number">0</span><span class="sh_symbol">;</span> i <span class="sh_symbol">&lt;</span> indexList<span class="sh_symbol">.</span><span class="sh_function">size</span><span class="sh_symbol">();</span> i<span class="sh_symbol">++)</span> <span class="sh_cbracket">{</span></li><li>            <span class="sh_keyword">if</span> <span class="sh_symbol">(</span>i <span class="sh_symbol">&gt;=</span> indexList<span class="sh_symbol">.</span><span class="sh_function">size</span><span class="sh_symbol">()</span> <span class="sh_symbol">-</span> <span class="sh_number">3</span><span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>                buttoms<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span>indexList<span class="sh_symbol">.</span><span class="sh_function">get</span><span class="sh_symbol">(</span>i<span class="sh_symbol">));</span></li><li>            <span class="sh_cbracket">}</span> <span class="sh_keyword">else</span> <span class="sh_keyword">if</span> <span class="sh_symbol">(</span>i <span class="sh_symbol">%</span> <span class="sh_number">3</span> <span class="sh_symbol">==</span> <span class="sh_number">0</span><span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>                zhangsan<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span>indexList<span class="sh_symbol">.</span><span class="sh_function">get</span><span class="sh_symbol">(</span>i<span class="sh_symbol">));</span></li><li>            <span class="sh_cbracket">}</span> <span class="sh_keyword">else</span> <span class="sh_keyword">if</span> <span class="sh_symbol">(</span>i <span class="sh_symbol">%</span> <span class="sh_number">3</span> <span class="sh_symbol">==</span> <span class="sh_number">1</span><span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>                lisi<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span>indexList<span class="sh_symbol">.</span><span class="sh_function">get</span><span class="sh_symbol">(</span>i<span class="sh_symbol">));</span></li><li>            <span class="sh_cbracket">}</span> <span class="sh_keyword">else</span> <span class="sh_cbracket">{</span></li><li>                wangwu<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span>indexList<span class="sh_symbol">.</span><span class="sh_function">get</span><span class="sh_symbol">(</span>i<span class="sh_symbol">));</span></li><li>            <span class="sh_cbracket">}</span></li><li>        <span class="sh_cbracket">}</span></li><li>        <span class="sh_comment">// 4. 看牌</span></li><li>        <span class="sh_function">pushBoss</span><span class="sh_symbol">();</span></li><li>        <span class="sh_function">check</span><span class="sh_symbol">(</span>pokerMap<span class="sh_symbol">,</span> zhangsan<span class="sh_symbol">,</span> <span class="sh_string">"张三"</span><span class="sh_symbol">);</span></li><li>        <span class="sh_function">check</span><span class="sh_symbol">(</span>pokerMap<span class="sh_symbol">,</span> lisi<span class="sh_symbol">,</span> <span class="sh_string">"李四"</span><span class="sh_symbol">);</span></li><li>        <span class="sh_function">check</span><span class="sh_symbol">(</span>pokerMap<span class="sh_symbol">,</span> wangwu<span class="sh_symbol">,</span> <span class="sh_string">"王五"</span><span class="sh_symbol">);</span></li><li>        <span class="sh_function">check</span><span class="sh_symbol">(</span>pokerMap<span class="sh_symbol">,</span> buttoms<span class="sh_symbol">,</span> <span class="sh_string">"底牌"</span><span class="sh_symbol">);</span></li><li>    <span class="sh_cbracket">}</span></li><li><span style="display:none;">&nbsp;</span></li><li>    <span class="sh_comment">/**</span></li><li><span class="sh_comment">     * 看牌</span></li><li><span class="sh_comment">     *</span></li><li><span class="sh_comment">     * </span><span class="sh_type">@param</span><span class="sh_comment"> pokerMap</span></li><li><span class="sh_comment">     * </span><span class="sh_type">@param</span><span class="sh_comment"> player   玩家扑克牌对应索引集合</span></li><li><span class="sh_comment">     * </span><span class="sh_type">@param</span><span class="sh_comment"> name     玩家昵称</span></li><li><span class="sh_comment">     */</span></li><li>    <span class="sh_keyword">public</span> <span class="sh_keyword">static</span> <span class="sh_type">void</span> <span class="sh_function">check</span><span class="sh_symbol">(</span><span class="sh_usertype">HashMap&lt;Integer, String&gt; pokerMap, TreeSet&lt;Integer&gt;</span><span class="sh_normal"> </span>player<span class="sh_symbol">,</span> <span class="sh_usertype">String</span><span class="sh_normal"> </span>name<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>        <span class="sh_comment">// 查看手中的牌</span></li><li>        System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">print</span><span class="sh_symbol">(</span>name <span class="sh_symbol">+</span> <span class="sh_string">"：["</span><span class="sh_symbol">);</span></li><li>        <span class="sh_keyword">for</span> <span class="sh_symbol">(</span><span class="sh_usertype">Integer</span><span class="sh_normal"> </span>i <span class="sh_symbol">:</span> player<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span></li><li>            System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">print</span><span class="sh_symbol">(</span>pokerMap<span class="sh_symbol">.</span><span class="sh_function">get</span><span class="sh_symbol">(</span>i<span class="sh_symbol">)</span> <span class="sh_symbol">+</span> <span class="sh_string">" "</span><span class="sh_symbol">);</span></li><li>        <span class="sh_cbracket">}</span></li><li>        System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">println</span><span class="sh_symbol">(</span><span class="sh_string">"]"</span><span class="sh_symbol">);</span></li><li>    <span class="sh_cbracket">}</span></li><li><span style="display:none;">&nbsp;</span></li><li>    <span class="sh_comment">/** 随机地主 */</span></li><li>    <span class="sh_keyword">public</span> <span class="sh_keyword">static</span> <span class="sh_type">void</span> <span class="sh_function">pushBoss</span><span class="sh_symbol">()</span> <span class="sh_cbracket">{</span></li><li>        <span class="sh_usertype">List&lt;String&gt;</span><span class="sh_normal"> </span>players <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> ArrayList<span class="sh_symbol">&lt;</span>String<span class="sh_symbol">&gt;();</span></li><li>        players<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span><span class="sh_string">"张三"</span><span class="sh_symbol">);</span></li><li>        players<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span><span class="sh_string">"李四"</span><span class="sh_symbol">);</span></li><li>        players<span class="sh_symbol">.</span><span class="sh_function">add</span><span class="sh_symbol">(</span><span class="sh_string">"王五"</span><span class="sh_symbol">);</span></li><li>        <span class="sh_usertype">Random</span><span class="sh_normal"> </span>r <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> <span class="sh_function">Random</span><span class="sh_symbol">();</span></li><li>        <span class="sh_type">int</span> bossIndex <span class="sh_symbol">=</span> r<span class="sh_symbol">.</span><span class="sh_function">nextInt</span><span class="sh_symbol">(</span><span class="sh_number">3</span><span class="sh_symbol">);</span></li><li>        <span class="sh_usertype">String</span><span class="sh_normal"> </span>boss <span class="sh_symbol">=</span> players<span class="sh_symbol">.</span><span class="sh_function">get</span><span class="sh_symbol">(</span>bossIndex<span class="sh_symbol">);</span></li><li>        System<span class="sh_symbol">.</span>out<span class="sh_symbol">.</span><span class="sh_function">println</span><span class="sh_symbol">(</span><span class="sh_string">"此局地主是："</span> <span class="sh_symbol">+</span> boss<span class="sh_symbol">);</span></li><li>    <span class="sh_cbracket">}</span></li><li><span class="sh_cbracket">}</span></li></ol></pre><pre class="snippet-textonly sh_sourceCode" style="display:none;">public class Main2 {
    public static void main(String[] args) {
        // 1.准备牌
        String[] arr1 = { "黑桃", "红桃", "方片", "梅花" };
        String[] arr2 = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };

        // 定义Map集合用来存放索引和牌
        HashMap&lt;Integer, String&gt; pokerMap = new HashMap&lt;&gt;();
        // 定义List集合存储索引（索引为0-53）
        List&lt;Integer&gt; indexList = new ArrayList&lt;&gt;();
        // 定义索引值变量
        int index = 0;
        // 将扑克牌与索引建立对应关系放入Map和List集合中
        for (String num : arr2) {
            for (String color : arr1) {
                pokerMap.put(index, color + num);
                indexList.add(index);
                index++;
            }
        }
        pokerMap.put(index, "小王");
        indexList.add(index++);
        pokerMap.put(index, "大王");
        indexList.add(index);

        // 定义玩家
        TreeSet&lt;Integer&gt; zhangsan = new TreeSet&lt;&gt;();
        TreeSet&lt;Integer&gt; lisi = new TreeSet&lt;&gt;();
        TreeSet&lt;Integer&gt; wangwu = new TreeSet&lt;&gt;();
        TreeSet&lt;Integer&gt; buttoms = new TreeSet&lt;&gt;();

        // 2. 洗牌
        Collections.shuffle(indexList);
        // 3. 发牌
        for (int i = 0; i &lt; indexList.size(); i++) {
            if (i &gt;= indexList.size() - 3) {
                buttoms.add(indexList.get(i));
            } else if (i % 3 == 0) {
                zhangsan.add(indexList.get(i));
            } else if (i % 3 == 1) {
                lisi.add(indexList.get(i));
            } else {
                wangwu.add(indexList.get(i));
            }
        }
        // 4. 看牌
        pushBoss();
        check(pokerMap, zhangsan, "张三");
        check(pokerMap, lisi, "李四");
        check(pokerMap, wangwu, "王五");
        check(pokerMap, buttoms, "底牌");
    }

    /**
     * 看牌
     *
     * @param pokerMap
     * @param player   玩家扑克牌对应索引集合
     * @param name     玩家昵称
     */
    public static void check(HashMap&lt;Integer, String&gt; pokerMap, TreeSet&lt;Integer&gt; player, String name) {
        // 查看手中的牌
        System.out.print(name + "：[");
        for (Integer i : player) {
            System.out.print(pokerMap.get(i) + " ");
        }
        System.out.println("]");
    }

    /** 随机地主 */
    public static void pushBoss() {
        List&lt;String&gt; players = new ArrayList&lt;String&gt;();
        players.add("张三");
        players.add("李四");
        players.add("王五");
        Random r = new Random();
        int bossIndex = r.nextInt(3);
        String boss = players.get(bossIndex);
        System.out.println("此局地主是：" + boss);
    }
}</pre></div></div>
运行上面程序，输出结果为：
<p class="info-box">
	此局地主是：张三<br>
	张三：[方片A 红桃2 方片2 黑桃4 红桃4 梅花4 红桃6 方片6 梅花6 黑桃7 红桃8 黑桃9 黑桃10 方片J 方片Q 黑桃K 红桃K ]<br>
	李四：[梅花2 黑桃3 红桃3 方片3 梅花3 红桃5 方片5 红桃7 梅花8 红桃9 梅花9 红桃10 梅花10 黑桃Q 梅花Q 梅花K 小王 ]<br>
	王五：[黑桃A 红桃A 黑桃2 方片4 黑桃5 黑桃6 方片7 黑桃8 方片8 方片9 方片10 黑桃J 红桃J 梅花J 红桃Q 方片K 大王 ]<br>
	底牌：[梅花A 梅花5 梅花7 ]</p>
</div>
			<div id="arc-append">
	<p>关注微信公众号「站长严长生」，在手机上阅读所有教程，随时随地都能学习。本公众号由<a class="col-link" href="http://c.biancheng.net/view/8092.html" target="_blank" rel="nofollow">C语言中文网站长</a>运营，每日更新，坚持原创，敢说真话，凡事有态度。</p>
	<p style="margin-top:12px; text-align:center;">
		<img width="180" src="./11.22Java项目实战：模仿斗地主洗牌发牌小游戏（附带源码和解析）_files/qrcode_weixueyuan_original.png" alt="魏雪原二维码"><br>
		<span class="col-green">微信扫描二维码关注公众号</span>
	</p>
</div>
<!-- <p>关注微信公众号「魏雪原」，跟着<a class="col-link" href="/view/8092.html" target="_blank">站长</a>一起学习，拒绝躺平，跳出内卷，用知识完成阶级跃升：</p>
	<ul>
		<li>每日更新，坚持原创，敢说真话，凡事有态度。</li>
		<li>编程+求职+创业+营销，既有硬知识，也有软技能。</li>
		<li>手机端阅读教程，随时随地都能学习。</li>
		<li>即将绑定网站部分功能，包括注册登录、找回密码、获取下载链接等。</li>
	</ul> -->
			<div class="pre-next-page clearfix">
                    <span class="pre left"><span class="icon">&lt;</span> <span class="text-brief text-brief-pre">上一页</span><a href="http://c.biancheng.net/view/6867.html">Java多对多关系示例</a></span>
                    <span class="next right"><a href="http://c.biancheng.net/java/120/">Java反射机制</a><span class="text-brief text-brief-next">下一页</span> <span class="icon">&gt;</span></span>
                </div>
			<div id="ad-arc-bottom"></div>

<!-- <div id="ad-bottom-weixin" class="clearfix">
	<div class="left" style="width: 535px;">
		<p><span class="col-red">编程帮</span>，一个分享编程知识的公众号。跟着<a class="col-link" href="/cpp/about/author/" target="_blank">站长</a>一起学习，每天都有进步。</p>
		<p>通俗易懂，深入浅出，一篇文章只讲一个知识点。</p>
		<p>文章不深奥，不需要钻研，在公交、在地铁、在厕所都可以阅读，随时随地涨姿势。</p>
		<p>文章不涉及代码，不烧脑细胞，人人都可以学习。</p>
		<p>当你决定关注「编程帮」，你已然超越了90%的程序员！</p>
	</div>
	<div class="right" style="width: 150px;">
		<img width="150" src="/templets/new/images/erweima_biancheng.gif?v=1.6.72" alt="编程帮二维码" /><br />
		<span class="col-green">微信扫描二维码关注</span>
	</div>
</div> -->

<div id="nice-arcs" class="box-bottom">
	<h4>优秀文章</h4>
	<ul class="clearfix">
<li><a href="http://c.biancheng.net/view/693.html" title="C++ valarray获取（访问）对象方法详解">C++ valarray获取（访问）对象方法详解</a></li>
<li><a href="http://c.biancheng.net/view/1450.html" title="C++字符串输入输出操作详解">C++字符串输入输出操作详解</a></li>
<li><a href="http://c.biancheng.net/view/1810.html" title="C语言while循环和do while循环详解">C语言while循环和do while循环详解</a></li>
<li><a href="http://c.biancheng.net/view/3823.html" title="汇编语言FPU寄存器栈（register stack）">汇编语言FPU寄存器栈（register stack）</a></li>
<li><a href="http://c.biancheng.net/view/5160.html" title="Hibernate Query接口 setEntity方法：用于绑定实体类参数">Hibernate Query接口 setEntity方法：用于绑定实体类参数</a></li>
<li><a href="http://c.biancheng.net/view/5480.html" title="Apollo服务端设计原理（源码解析）">Apollo服务端设计原理（源码解析）</a></li>
<li><a href="http://c.biancheng.net/view/5661.html" title="JS数组添加和删除元素（多种方法）">JS数组添加和删除元素（多种方法）</a></li>
<li><a href="http://c.biancheng.net/view/6385.html" title="IP地址是什么？">IP地址是什么？</a></li>
<li><a href="http://c.biancheng.net/redis2/getrange.html" title="Redis GETRANGE命令">Redis GETRANGE命令</a></li>
<li><a href="http://c.biancheng.net/pandas/window-functions.html" title="Python Pandas窗口函数">Python Pandas窗口函数</a></li>
</ul>
</div>
		</div>
		
	</div>
</div>
<script type="text/javascript">
// 当前文章ID
window.arcIdRaw = 'a_' + 7080;
window.arcId = "a38frj8VOuqNqYN8o/kQ3GTpKDuDBUGThvTWBQ+Ba4KFQ9mq6pCsEVEaWr0";
window.typeidChain = "103|79";
</script>
<div id="footer" class="clearfix">
	<div class="info left">
	<p>精美而实用的网站，分享优质编程教程，帮助有志青年。千锤百炼，只为大作；精益求精，处处斟酌；这种教程，看一眼就倾心。</p>
	<p>
		<a href="http://c.biancheng.net/view/8066.html" target="_blank" rel="nofollow">关于网站</a> <span>|</span>
		<a href="http://c.biancheng.net/view/8092.html" target="_blank" rel="nofollow">关于站长</a> <span>|</span>
		<a href="http://c.biancheng.net/view/8097.html" target="_blank" rel="nofollow">如何完成一部教程</a> <span>|</span>
		<a href="http://c.biancheng.net/view/8093.html" target="_blank" rel="nofollow">联系我们</a> <span>|</span>
		<a href="http://c.biancheng.net/sitemap/" target="_blank" rel="nofollow">网站地图</a>
	</p>
	<p>Copyright ©2012-2021 biancheng.net, <a href="http://www.beian.miit.gov.cn/" target="_blank" rel="nofollow" style="color:#666;">陕ICP备15000209号</a></p>
	</div>
	<img class="right" src="./11.22Java项目实战：模仿斗地主洗牌发牌小游戏（附带源码和解析）_files/logo_bottom.gif" alt="底部Logo">
	<span id="return-top"><b>↑</b></span>
</div>

<script type="text/javascript">
window.siteId = 4;
window.cmsTemplets = "/templets/new";
window.cmsTempletsVer = "1.6.72";
</script>

<script src="./11.22Java项目实战：模仿斗地主洗牌发牌小游戏（附带源码和解析）_files/jquery1.12.4.min.js.下载"></script>
<script src="./11.22Java项目实战：模仿斗地主洗牌发牌小游戏（附带源码和解析）_files/common.js.下载"></script>
<span style="display:none;"><script src="./11.22Java项目实战：模仿斗地主洗牌发牌小游戏（附带源码和解析）_files/z_stat.php" type="text/javascript" defer="defer" async="async"></script></span>

</body></html>